package com.bdqn.controller;


import com.bdqn.entity.PmsSpu;
import com.bdqn.entity.allParams.PmsSpuParam;
import com.bdqn.entity.util.RespBean;
import com.bdqn.service.PmsSpuService;
import com.bdqn.util.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 商品spu表 前端控制器
 * </p>
 *
 * @author hunter
 * @since 2022-04-30
 */
@RestController
@RequestMapping("/pms/product")
public class PmsSpuController {
    @Autowired
    private PmsSpuService pmsSpuService;

    @PostMapping("/search")
    public RespBean search(@RequestBody PmsSpuParam pmsSpecParam) {
        System.out.println("后台接收的信息为 页面大小" + pmsSpecParam.getPageSize());
        System.out.println("后台接收的信息为  分类id" + pmsSpecParam.getProductLevel2CategoryId());
        PageDto<PmsSpu> pageDto = pmsSpuService.spuPage(pmsSpecParam);
        if (pageDto != null) {
            return RespBean.ok("获取分页列表成功", pageDto);

        } else {
            return RespBean.err("获取分页列表失败");
        }
    }

    @GetMapping("/detail")
    public RespBean getPmsSpuDtoById(@RequestParam("spuId") Long id) {
        return RespBean.ok("获取商品详情spu+sku信息成功",     pmsSpuService.getPmsSpuDtoById(id));
    }
}
